import request from "../utils/request";

export const fetchHomeNav = () =>
  request({
    url: "/mock/Home/navList.json",
  });
export const getCateList = () =>
  request({
    url: "/mock/Cate/cateList.json",
  });
export const fecthNiceLists = () => {
  return request({
    url: "/api/goods/nine/one-hour-goods",
  });
};

export const fetchPostAgeNav = () => {
  return request({
    url: "/api/category/nine/cate-list/v1-new",
  });
};

export const fecthGoodLists = (
  cid: number,
  pageNo: number,
  pageSize: number
) => {
  return request({
    url: "/api/goods/nine/nine-goods-list",
    data: {
      cid,
      pageNo,
      pageSize,
    },
  });
};

export const fecthMoreLists = (
  cid: number,
  pageNo: number,
  pageSize: number
) => {
  return request({
    url: "/api/goods/nine/nine-goods-list",
    data: {
      cid,
      pageNo,
      pageSize,
    },
  });
};

export const fetchCateList = ({
  cid,
  type,
  r,
}: {
  cid: string;
  type: string;
  r: string;
}) =>
  request({
    url: `/index.php`,
    data: {
      r,
      page: 1,
      cid,
      px: type,
      cac_id: "",
    },
  });
export const fetchFood = ({
  cid,
  type,
  r,
}: {
  cid: string;
  type: string;
  r: string;
}) =>
  request({
    url: "/index.php",
    data: {
      r,
      page: 1,
      cid,
      px: type,
      cac_id: "",
    },
  });

export const fetchHomeChooseList = () =>
  request({
    url: "/mock/Home/footerChooseList.json",
  });
export const fetchPickList = (val: string) =>
  request({
    url: `/mock/Pick/${val}.json`,
  });
export const fetchTicketList = (categoryId: string) =>
  request({
    url: "/api/category/single/page/get-goods-by-categoryId",
    data: {
      categoryId,
      pageNo: 1,
      pageSize: 10,
      singlePageId: 2,
    },
  });
export const fetchTicketTabs = () =>
  request({
    url: "/api/category/single/page/get-single-page",
    data: {
      pageId: 2,
      tuserId: 771131,
      entityId: "",
    },
  });
export const fetchNavlist = () => {
  return request({
    url: "api/goods/rushing-ranking/cate-list/v1",
  });
};

export const fetchCrazylist = (type: number, cId: number) => {
  return request({
    url: `/api/goods/rushing-ranking/goods-list2/v2`,
    data: {
      cId,
      type,
    },
  });
};

export const fetchHalfList = () => {
  return request({
    url: "/mock/Half/halfList.json",
  });
};

export const fetchDiscountList = (cId: number) => {
  return request({
    url: "/api/goods/super-discount/goods-list/v1",
    data: {
      cId,
    },
  });
};
export const fetchDiscountNav = () => {
  return request({
    url: "/api/goods/super-discount/cate-list/v1",
  });
};

export const fetchDiscountSuper = () => {
  return request({
    url: "/api/goods/super-discount/get-grab-today",
  });
};

export const fetchBrandNav = () => {
  return request({
    url: "/api/goods/category-brand-list",
  });
};

export const fetchBrandData = (type: string) => {
  return request({
    url: `/api/tb-service/get-${type}-data`,
  });
};

export const fetchBrandList = (typeId: number) => {
  return request({
    url: "/api/tb-service/brand-list-by-category-id",
    data: {
      typeId,
    },
  });
};

export const fetchRegister = (data: { username: string; password: string }) =>
  request({
    url: "http://59.110.226.77:3000/api/user/register",
    data,
    method: "POST",
  });
export const fetchLogin = (data: { username: string; password: string }) =>
  request({
    url: "http://59.110.226.77:3000/api/user/login",
    data,
    method: "POST",
  });
export const fetchFoodList = () =>
  request({
    url: "/index.php?r=class/index&type=2",
    method: "POST",
  });
export const fetchFoodlist = (cid: string, px: any) =>
  request({
    url: "/index.php?r=index/ajaxcat",
    method: "POST",
    data: {
      cid,
      px,
      token:
        "a7X38EljwHtrN1Ncyp7ilsp5DP2zZr_F15OrMg-_wR9eQdkM_Be-V4tF2ZlyAugEPlDeBr4SZocv-Iu16u6YWxrFvez31sMYfmV-ysAdNNY",
      advVersion: 1,
      page: 1,
      cac_id: "",
    },
  });
export const fetchMotherList = () =>
  request({
    url: "/api/category/single/page/get-single-page?pageId=1&tuserId=771131&entityId=",
  });
export const fetchMotherCate = (categoryId: number) =>
  request({
    url: `/api/category/single/page/get-goods-by-categoryId?pageNo=1&pageSize=10&singlePageId=1`,
    data: {
      categoryId,
    },
  });
export const fetchToken = (token: string | undefined) =>
  request({
    url: "https://www.fastmock.site/mock/5efb10c9c15e9c47ccf56e394363b1f0/api/checkToken",
    method: "GET",
    data: {
      token,
    },
  });
export const fetchHomeProduct = (data: any) =>
  request({
    url: "/api/category/product/model-detail-by-model-id-new",
    data,
  });
export const fetchHomeHome = (data: any) =>
  request({
    url: "/api/category/home/model-detail-by-model-id-new-revision",
    data,
  });
export const fetchSearch = (kw: string) =>
  request({
    url: "/index.php",
    data: {
      r: "index/kwarr",
      kw,
      token:
        "a7X38EljwHtrN1Ncyp7ilsp5DP2zZr_F15OrMg-_wR9eQdkM_Be-V4tF2ZlyAugEPlDeBr4SZocv-Iu16u6YWxrFvez31sMYfmV-ysAdNNY",
    },
  });
export const fetchHomeHeader = () =>
  request({ url: "/api/category/get-category-list" });

export const fetchHomeFooterFind = (data: any) =>
  request({
    url: "/api/category/index/lingquan-live-new",
    data,
  });

export const fetchHomeFooterChoose = (data: any) =>
  request({
    url: "/api/goods/guess-you-like",
    data,
  });
